-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix env transforms in node_modules #2073
Conversation
…ges and don't dedupe env plugins on unknown environments
Apparently the linux test-runners are down. The scope-hoisting tests are using experimental JS in some tests so babel is complaining. I'll try to find some time soonish to dig deeper into fixing that. I just hope nobody publishes code with unstandardized JS, otherwise this would be a breaking change. @fathyb you have any idea if this would affect scope-hoisting a lot? And whether this PR is even a good idea at all. |
As far as scope-hoisting goes I think it'll be okay as soon as it doesn't add the commonjs transform. |
Hmm I don't know that we want to change this. We currently assume that node_modules is already compiled by default, unless a |
@devongovett originally thought the logic was assuring the entire bundle matches a certain browserslist. This is the only way I could think of achieving that as defining a browserslist or engines field in a package is optional. Perhaps we could allow some way to enable this, for people who really want full browser compatibility? Not sure if this is a good idea or not, seems to break the moment anything has unstandardised JS. |
node_modules shouldn't contain non-standard code for sure, but historically node_modules has been ES5 as well, meaning pre-babelified. This ensures the most interoperability between tools. Parcel takes this as the default, and assumes that if no other information is specified, the code is already pre-compiled to ES5. However, people are starting to target newer versions of node/browsers in their node_modules, so we added support for specifying that in |
Alright so people should just change their package.json, got it. |
I just stumbled upon are-you-es5 which tries to parse each dependency with acorn to tell if it is valid es5 or not. I guess Parcel could check dependencies before bundling or the generated bundles with this or a similar approach and transpile them in case they do not fit the target environment. Maybe behind a flag for performance reasons. Update: es-check does the same but is more popular. |
name: 🙋 New Pull Request
about: Do you want to change something on parcel?
↪️ Pull Request
I'm not sure if this is what should happen, as there where 2 unit tests stating that the modules should not be converted to match the global browser versions. Which seems kinda strange to me as that is the only reason preset-env is being ran over node_modules afaik?
This PR, removes the fallback to engines.node for target detection in case of targeting browsers as this is often an invalid indicator for browser specific modules.
Closes #1887
💻 Examples
✔️ PR Todo